package net.greyar.theory;

import java.util.List;
import java.util.Map;

public class Literal extends Symbol {
	public Literal(String token) {
		this.token = token;
		this.print = token;
	}
	@Override
	protected StringBuilder toString(StringBuilder sb) {
		sb.append(token);
		return sb;
	}
	@Override
	protected StringBuilder getPrint(StringBuilder sb) {
		sb.append(print);
		return sb;
	}
	@Override
	public boolean occurs(Variable variable) {
		return false;
	}
	@Override
	public Substitution unify(Symbol other, Substitution sigma) {
		if (other instanceof Literal) {
			return token.equals(other.getToken()) ? sigma : null;
		}
		return other.unify(this, sigma);
	}
	@Override
	public Symbol apply(Substitution sigma, Map<String, Variable> variables) {
		return new Literal(token);
	}
	@Override
	protected List<Variable> getVariables(List<Variable> variables) {
		return variables;
	}
	@Override
	protected Symbol level() {
		return this;
	}
	@Override
	protected boolean grounds(Substitution sigma) {
		return true;
	}
	@Override
	public String getKey() {
		return token;
	}
}
